/*
 * RPointerStack.h
 *
 *  Created on: 2010-4-10
 *      Author: Administrator
 */

#ifndef RPOINTERSTACK_H_
#define RPOINTERSTACK_H_

//#include <e32cmn.h>

template <class T>
class RPointerStack
	{
public:
	RPointerStack()
		{
	
		}
	
	TInt Count()
		{
		return iArray.Count();
		}
	
	void PushL(T* aObj)
		{
		iArray.AppendL(aObj);
		}
	
	void PopAndDestroy()
		{
		T* iDel = iArray[iArray.Count()-1];
		iArray.Remove(iArray.Count()-1);
		delete iDel;
		iDel = NULL;
		}
	
	void Pop()
		{
		iArray.Remove(iArray.Count()-1);
		}
	
	T* Top()
		{
		if(iArray.Count()>0)
			return iArray[iArray.Count()-1];
		else
			return NULL;
		}
	
	void Close()
		{
		iArray.ResetAndDestroy();
		iArray.Close();
		}
	
	void ResetAndDestroy()
		{
		iArray.ResetAndDestroy();
		}
private:
	RPointerArray<T> iArray;
	};

#endif /* RPOINTERSTACK_H_ */
